/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author melchiorin
 */
class WorkingMemory {
	private List<Rule> rules = new ArrayList<Rule>()
        private List<String> memory

        public void addRule(rule){
            rules.add(rule)
            rule.conclusions.each{ key, value ->
                if(!memory.contains(new String("${key}=${value}")))
                    memory.add("${key}=${value}")
            }
        }

        public String toString(){
            def string = ""
            rules.each{
                string += it.toString()
            }
            return string
        }

    public String getConclusions(){
        def con = ""
        rules.each{
            con += it.getConclusionsString()
        }
        return con;
    }

    public boolean isInMemory(Rule rule){
        return rules.contains(rule)
    }

    public void printMemory(){
        memory.each{
            print it + ","
        }
        print "\n"
    }
}

